-
Notifications
You must be signed in to change notification settings - Fork 648
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Implement --annotation-style
parameter for uv pip compile
#1679
feat: Implement --annotation-style
parameter for uv pip compile
#1679
Conversation
--annotation-style
parameter for uv pip compile
--annotation-style
parameter for uv pip compile
Thanks for contributing! Welcome to the project :) I'm not entirely sure we want to accept more configuration here, I'll need to check with @charliermarsh. It looks like the Windows snapshots are failing. We automatically filter out some Windows-only dependencies, but it's failing since they're not separated by a newline anymore. You'll need to adjust the regex at uv/crates/uv/tests/common/mod.rs Lines 261 to 264 in ad12d97
|
@zanieb I hope you'll accept this one :) Regarding the tests - fixed! |
crates/uv-resolver/src/resolution.rs
Outdated
} | ||
} | ||
} | ||
// Assemble the line with the annotations and remove trailing whitespaces. | ||
line = format!("{line:24}{sep}{annotation}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you walk me through line:24
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure! I'm trying to keep the same logic, as pip-tools
, to minimize the diff in the output file. The align 24
is something they use in the pip-tools
as a reasonable number to align the annotation comments: https://github.com/jazzband/pip-tools/blob/main/piptools/writer.py#L318 and I agree with them. Most of the time annotation will be aligned except for some extra-long dependencies.
monotonic==1.6 # via analytics-python
oauthlib==2.1.0 # via pyproject.toml
opentelemetry-api==1.22.0 # via ddtrace
packaging==21.3 # via gunicorn, pyproject.toml
prompt-toolkit==3.0.43 # via click-repl
protobuf==4.25.3 # via ddsketch, ddtrace
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh okay, thank you, perfect!
I'm wondering if we should just put more of this method within a match
on the annotation style. I might find the logic easier to follow, but I'd need to see it to know for sure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean to extract annotation_line
and annotation_split
onto the match
statement? I could do this, they're not very big, should be fine
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, you're right, it's easier to read without those function calls :)
I'm happy to include this. |
00f6ddb
to
4d71213
Compare
I have no idea, why it's failing 🤔 UPD: Fixed 😊 |
4d71213
to
3a119e3
Compare
3a119e3
to
b2a12b4
Compare
Will review and merge tonight, hopefully. |
3ec4eee
to
8c82063
Compare
fe16f34
to
5d579e1
Compare
} | ||
} | ||
|
||
if let Some((separator, comment)) = annotation { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@DrJackilD -- I just tweaked this to couple the presence of the comment and separator.
5d579e1
to
d22aa3e
Compare
Thank you! Great contribution. |
Thank you for accepting it so quick! |
Summary
Hello there! The motivation for this feature is described here #1678
Test Plan
I've added unit tests and also tested this manually on my work project by comparing it to the original
pip-compile
output - it looks much like thepip-compile
generated lock file.